package dao.pojo;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.TableGenerator;

/**
 * TAuthority entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "t_authority", catalog = "fw")
public class Authority extends BasePojo implements java.io.Serializable {

	// Fields

	private String authority;
	private Set<ResourceAuthority> resourceAuthorities = new HashSet<ResourceAuthority>(
			0);
	private Set<GroupAuthority> groupAuthorities = new HashSet<GroupAuthority>(
			0);

	// Constructors

	/** default constructor */
	public Authority() {
	}

	/** minimal constructor */
	public Authority(String authority) {
		this.authority = authority;
	}


	// Property accessors
	@Id
	@TableGenerator(name = "AUTHORITY_GEN", table = "sequence", pkColumnName = "SEQ_NAME", valueColumnName = "SEQ_COUNT", pkColumnValue = "SEQ_AUTHORITY", allocationSize = 1)
	@GeneratedValue(strategy = GenerationType.TABLE, generator = "AUTHORITY_GEN")
	@Column(name = "Authority", unique = true, nullable = false, length = 50)
	public String getAuthority() {
		return this.authority;
	}

	public void setAuthority(String authority) {
		this.authority = authority;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "authority")
	public Set<ResourceAuthority> getResourceAuthorities() {
		return resourceAuthorities;
	}

	public void setResourceAuthorities(Set<ResourceAuthority> resourceAuthorities) {
		this.resourceAuthorities = resourceAuthorities;
	}
	

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "authority")
	public Set<GroupAuthority> getGroupAuthorities() {
		return groupAuthorities;
	}

	public void setGroupAuthorities(Set<GroupAuthority> groupAuthorities) {
		this.groupAuthorities = groupAuthorities;
	}
	
	public Object getEntityId(){
		return this.authority;
	}

}